import request from '@/config/axios'

// 生产任务单主表 VO
export interface ProductionOrderVO {
  id: number // id
  serialNumber: string // 流水号
  deptId: number // 部门id
  orderDate: Date // 订单日期
  remark: string // 备注
  auditor: string // 审核人
  auditTime: Date // 审核时间
}

// 生产任务单子表 VO
export interface ProductionOrdersVO {
  id: number // 
  pid: number // 
  inventoryId: number // 
  inventoryCode: any // 
  inventoryName: any // 
  inventorySpecModel: any // 
  inventoryUnitName: any // 
  inventoryBrand: any
  remark: any // 
  inQuantity: any // 
  quantity: any //
}

// 生产任务单主表 API
export const ProductionOrderApi = {
  // 查询生产任务单主表分页
  getProductionOrderPage: async (params: any) => {
    return await request.get({ url: `/wms/production-order/page`, params })
  },

  // 查询生产任务单主表详情
  getProductionOrder: async (id: number) => {
    return await request.get({ url: `/wms/production-order/get?id=` + id })
  },

  // 新增生产任务单主表
  createProductionOrder: async (data: ProductionOrderVO) => {
    return await request.post({ url: `/wms/production-order/create`, data })
  },

  // 修改生产任务单主表
  updateProductionOrder: async (data: ProductionOrderVO) => {
    return await request.put({ url: `/wms/production-order/update`, data })
  },

  // 删除生产任务单主表
  deleteProductionOrder: async (id: number) => {
    return await request.delete({ url: `/wms/production-order/delete?id=` + id })
  },

  // 导出生产任务单主表 Excel
  exportProductionOrder: async (params) => {
    return await request.download({ url: `/wms/production-order/export-excel`, params })
  },
 // 查询需要入库生产任务单
 findProductionOrderOperateList: async () => {
  return await request.get({ url: `/wms/production-order/findProductionOrderOperateList` })
},

    //提交
    submit: async (id: number) => {
      return await request.get({ url: `/wms/production-order/startProcess?id=` + id })
    },

// ==================== 子表（生产任务单子） ====================

  // 获得生产任务单子列表
  getProductionOrdersListByPid: async (pid) => {
    return await request.get({ url: `/wms/production-order/production-orders/list-by-pid?pid=` + pid })
  },

  getProductionOrdersOperateList: async (params: any) => {
    return await request.get({ url: `/wms/production-order/production-orders/operateList`, params })
  },
  getProductionOrdersById: async (id) => {
    return await request.get({ url: `/wms/production-order/getProductionOrdersById?id=` + id })
  },


  
}
